package com.dk.logc.utils;

import com.dk.logc.kafka.base.BaseRoleFlog;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author 林道敬
 * @Date 2024-01-08
 * @Description
 **/

@Component
public class ReportUtil {

    @Autowired
    private KafkaTemplate<Object,Object> kafkaTemplate;

    /**
     * 同步发送
     * @return
     * @throws
     * @throws InterruptedException
     */
    @Transactional
    @Async
    public void doPost(final BaseRoleFlog baseRoleFlog) {

        ProducerRecord record = new ProducerRecord("springCloudBus", baseRoleFlog);
        kafkaTemplate.send(record);
    }
}
